<template>
	<view style="margin:30rpx;">
		<view class="flex vessel">
			<view class="marginRight titleColor">手机号码</view>
			<view style="margin: auto;">
				<u-input v-model="form.phone" :clearable="false" placeholder="请输入手机号码"/>
			</view>
		</view>
		<view class="flex vessel">
			<view class="marginRight titleColor">真实姓名</view>
			<view style="margin: auto;">
				<u-input v-model="form.realname" :clearable="false" placeholder="请输入微信钱包真实姓名"/>
			</view>
		</view>
		<view class="flex vessel" style="justify-content: space-between;">
			<view class="marginRight titleColor">账户余额</view>
			<view class="flex">
				<view style="color: #B5B5B5;">￥{{available_money}}</view>
				<view class="allWithDraw" @click="form.amount = available_money">全部提现</view>
			</view>
		</view>
		<view class="flex vessel">
			<view class="marginRight">
				<view style="color: #303133;margin-bottom: 5px;">提现金额(元)</view>
				<!-- <view style="color: #303133;margin-bottom: 5px;line-height: 35px;">提现金额(元)</view>
				<view style="font-size: 12px;color: #bbb;line-height: 0;">每次最低提现 ￥1</view> -->
			</view>
			<view style="margin: auto;margin-left: 70rpx;">
				<u-input v-model="form.amount" :clearable="false"  placeholder="请输入提现金额"/>
			</view>
		</view>
		
		<view style="margin: 100rpx;">
			<button style="background-color: #0CC260;color: #FFFFFF;" @click="withDraw()">确认提现</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				available_money:0,
				form:{
					phone:"",
					realname:"",
					amount:"",
					user_token:wx.getStorageSync("userToken")
				}
			}
		},
		onLoad(options) {
			this.available_money = options.available_money //账户余额
		},
		methods: {
			withDraw(){ 
				console.log(this.form)
				this.$api.applyWithdrawal(this.form,this.$baseUrl).then(res=>{
					if(res.data.level=="success"){
						wx.showToast({
							title:res.data.message,
							icon:"success"
						})
						setTimeout(()=>{
							wx.navigateBack({
								delta:1
							})
						},1500)
					}else{
						wx.showToast({
							title:res.data.message,
							icon:"none"
						})
					}
				})
			}
		}
	}
</script>

<style scoped>
	.flex {
		display: flex;
		justify-content: flex-start;
	}
	.vessel{
		height: 60px;line-height: 60px;margin-bottom: 5px;
		
		border-bottom: 1px solid #e8e8e8;
	}
	.titleColor{
		color: #303133;
	}
	.marginRight{
		margin-right: 20rpx;
	}
	.allWithDraw{
		margin-left: 150rpx;margin-right: 50rpx;color: #0CC260;
	}
</style>
